# -*- coding: utf-8 -*-
"""
Created on Wed Aug  3 08:42:46 2016

@author: XT-YY

test for interact with calendar control in web crawler
"""
from selenium import webdriver
from splinter import Browser
import pandas as pd
import time
import os

"""
method one
"""

#if __name__ == "__main__":
#    url = r"http://www.sse.com.cn/disclosure/credibility/supervision/change/"
##    driver = webdriver.PhantomJS()
#    driver = webdriver.Firefox()
#    driver.get(url)
#    time.sleep(3)
#    xpath = '//*[@id="start_date"]'
#    inputbox = driver.find_element_by_xpath(xpath)
#    driver.execute_script("arguments[0].removeAttribute('readonly','readonly')",inputbox)
#    inputbox.clear()
#    inputbox.send_keys("2016-08-01")
#    
#    searchbox = driver.find_element_by_id("btnQuery")
#    searchbox.click()
#    driver.close()


"""
method two
"""
if __name__ == "__main__":
    url = r"http://www.sse.com.cn/disclosure/credibility/supervision/change/"
#    browser = Browser('phantomjs', user_agent="Mozilla/5.0 (Windows NT 6.1; WOW64) \
#        AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36")
    browser = Browser()
    browser.driver.maximize_window()
    browser.visit(url)
    time.sleep(3)
    browser.execute_script(r'document.getElementById("start_date").removeAttribute("readonly")')
    browser.find_by_id("start_date").fill('2016-08-01')
    browser.quit()
  
    